import java.util.Random;
import java.util.Scanner;

public class guessNum {
     public static void toGuess(int num2)
     {
         //设置猜数字的次数
         int count = 5;
         Scanner sc = new Scanner(System.in);
         for(int i = count;i > 0;i--)
         {
             System.out.print("请输入你要猜的数：");
             int num1 = sc.nextInt();
             if(num1 < num2)
                 System.out.println("猜小了,你还有" + (i - 1) + "次机会");
             else if(num1 > num2)
                 System.out.println("猜大了" + (i - 1) + "次机会");
             else if(num1 == num2)
             {
                 System.out.println("恭喜你猜对了，未知数是：" + num1);
                 break;
             }
             if(i == 1)
                 System.out.println("你的次数用光了，未知数是：" + num2);

         }
         sc.close();
     }
    public static void main(String[] args) {
         //生成默认系统时间戳
         Random re = new Random();
         //num的取值范围为1-100
        int num = re.nextInt() % 100 + 1;
        toGuess(num);
    }
}
